package com.pa.chong.pachong.tool.utils;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicInteger;

public class MyFuture extends FutureTask {

    private static AtomicInteger integer = new AtomicInteger(1);

    public MyFuture(Callable<String> callable) {
        super(callable);
    }

    @Override
    protected void done() {
        try {
            System.out.println(get() + " 线程执行完毕！~"+integer);
            if(integer.get()==30){
                System.out.println("GAME OVER!!!!!!!!!!!");
            }
            integer.incrementAndGet();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
    }
}
